Ext.define('iMedproplus.view.admin.dictionary.Icd9Window', {
    extend: 'Ext.window.Window',
    requires: [
    'iMedproplus.view.admin.dictionary.Icd9Grid',
    'Ext.grid.PagingScroller'
    ],
    alias: 'widget.admindictionaryicd9window',
    height: 350,
    width: 300,
    title: 'S\u0142ownik procedur Icd9',
    maximizable: true,
    modal: true,
    layout: {
        align: 'stretch',
        type: 'vbox'
    },
    
    initComponent: function() {
        var me = this;
        Ext.applyIf(me, {
            items: [
            {
                xtype: 'panel',
                layout: {
                    align: 'stretch',
                    type: 'fit'
                },
                border: 0,
                flex: 1,                    
                dockedItems: [
                {
                    xtype: 'toolbar',
                    items: [
                    {
                        xtype: 'button',
                        text: 'Wczytaj Icd9 z pliku XML',
                        listeners: {
                            click: {
                                fn: me.onUploadIcd9FromXmlButtonClick,
                                scope: me
                            }
                        }
                    }
                    ]
                }],
                items: [
                {
                    xtype: 'admindictionaryicd9grid',
                    flex: 1
                }
                ]
            }
            ],
            listeners : [
            {
                beforeshow : me.onBeforeWindowShow,
                scope : me
            }
            ]
        });
        me.callParent(arguments);
    },
    
    onUploadIcd9FromXmlButtonClick: function(){
        var window = Ext.widget('adminuploadwindow');
        window.callback = function(){
            Ext.App.getStore('iMedproplus.store.Icd9').load();
            console.log('callback');
        }
        window.url = 'upload/icd9/sendfile.json';
        window.show();
    },
    
    onBeforeWindowShow: function(){
        console.log('before');
    }

});